import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:robot3/services.dart';
import 'package:robot3/widgets.dart';

class BackButton1 extends StatelessWidget {
  final void Function(String) onClick;

  const BackButton1({super.key, this.onClick = _defaultOnClick});

  static void _defaultOnClick(String text) {
    SystemNavigator.pop();
  }

  @override
  Widget build(BuildContext context) {
    return MyButton01(
      text: "返回",
      containerColor: Colors.white,
      textColor: MyBlack,
      size: Size(148.0/ratio, 48.0/ratio),
      fontSize: 24.0/ratio,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(10.0/ratio)),
      ),
      onClick: (text) {
        onClick(text);
        // Navigator.of(context).pop();
      },
    );
  }
}

///使用的地方有 客户信息 渲染详情
class ConfirmButton extends StatelessWidget {
  final void Function(String) onClick;

  final String  text;

  final bool  enable;

  final double  width;

  const ConfirmButton({super.key, this.onClick = _defaultOnClick, required this.text, this.enable =  true, this.width = 156.0/ratio });

  static void _defaultOnClick(String text) {
    SystemNavigator.pop();
  }

  @override
  Widget build(BuildContext context) {
    return MyButton01(
      text: text,
      containerColor:  enable ? MyBLUE : MyBLUE.withOpacity(0.6) ,
      textColor: Colors.white,
      size: Size(width, 48.0/ratio),
      fontSize: 24.0/ratio,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(10.0/ratio)),
      ),
      onClick: (text) {
        onClick(text);
        // Navigator.of(context).pop();
      },
    );
  }
}

class CancelButton extends StatelessWidget {
  final void Function(String) onClick;

  final String  text;

  final double  width;

  const CancelButton({super.key, this.onClick = _defaultOnClick,  this.text = "取消", this.width = 156.0/ratio });

  static void _defaultOnClick(String text) {
    SystemNavigator.pop();
  }

  @override
  Widget build(BuildContext context) {
    return MyButton01(
      text: text,
      containerColor: MyBlack.withOpacity(0.10),
      textColor: MyBlack,
      size: Size(width, 48.0/ratio),
      fontSize: 24.0/ratio,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(10.0/ratio)),
      ),
      onClick: (text) {
        onClick(text);
        // Navigator.of(context).pop();
      },
    );
  }
}



